home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / wild / appunti / wildprefs.txt < prev    next >
Text File  |  1999-01-01  |  3KB  |  83 lines

  1.  
  2. WildPrefs.library design info.
  3.  
  4. This library must handle prefs loading, setting and saving.
  5. So, also files in the ENV directory, and more.
  6.  
  7. Wild will call this in the AddWildApp func, if the WIAP_HandlePrefs
  8. is specified: so, if you want your app to be handled by prefs, set it.
  9. If you do, your tags will be replaced by the prefs defined tags, so
  10. may be completely different from what you want: you can only suggest
  11. the first config to be used by your app, but you cannot be sure of 
  12. what your app will use. That's obviously normal.
  13.  
  14. Your app will be identified by WildPrefs.library by your WIAP_BaseName:
  15. so, give a short name, please...
  16.  
  17. funcs to implement:
  18.  
  19. - GetHandledList(): will give you the list of the Handled apps. So,
  20.   will list all the prefs files in the ENV dir, but will NOT OPEN 
  21.   them! Just gives you the list, if you want to change something,
  22.   you must call LoadPrefs. 
  23.   The list will contain a particular struct, containing all the 
  24.   prefs things, but EMPTY apart the NAME: you will pass this to LoadPrefs.
  25.  
  26. - LoadPrefs(app,tags): will initialize the app struct (empty, with only the NAME)
  27.   with the values contained in the prefs file, or with default values if no
  28.   prefs file is found. Tags will contain the values used as default if no
  29.   value is found for some tags.
  30.  
  31. - FindNamedApp(name): will find an app in the Handled list, or will create one
  32.   if no match is be found. An empty prefs file will be created.
  33.   
  34. - SetPrefs(app,tags): will set some tags for this app, without applying them in any way.
  35.  
  36. - TestPrefs(app): will test the prefs on the app, but no filesave done.
  37. - UsePrefs(app): will use the prefs on the app, and save them in ENV:.
  38. - SavePrefs(app): will use the prefs on the app, and save them in ENV: and ENVARC:.
  39. - FreePrefs(app): will free the prefs struct, close all files. The app struct
  40.   will be emptyed apart the name.
  41.  
  42. The path of prefs is:
  43.  
  44. ENV(ARC):Wild/
  45.  
  46. The filename for prefs is:
  47.  
  48. wild.prefs for the general wild optionsfile
  49. _APPNAME.prefs for the specific app file. 
  50.  
  51. The _ is used to avoid conflicts with wild.prefs and future ??.prefs files.
  52. The Wild drawer is created everytime it is not present.
  53. The GetHandledList() will look first in the ENV: assignement (if present)
  54. and then in the ENVARC:.
  55.  
  56. The PrefsFileFormat:
  57.  
  58. Must only contain tags.
  59. But some tags are strings !!
  60. So, use the FileTag struct:
  61.  
  62.     Structure FileTag
  63.         BYTE    ft_Flags
  64.         BYTE    ft_Len
  65.         LONG    ft_Tag
  66.         LABEL    ft_Data
  67.  
  68. A flag is the Pointer flag: does the data is included in the tag or is
  69. pointed by the tag ?
  70.         
  71. Problem in SavePrefs: how know if a tag is a string tag or not !?
  72. Simple: 
  73.  
  74. - for standard defined WILD tags, use default NON-string tags and make
  75.   a file of the complex tags. (ENVARC:Wild/Complex.tags)
  76.   
  77.   Structure ComplexTagsFile
  78.       WORD    ct_Num
  79.       LABEL   ct_Data        (ARRAY OF LONG, NOT OF TAGS!!)
  80.       
  81. - for non-standard, define 2 wilduser tagbases: one for simple, one for complex.  
  82.  
  83.